//
//  ChannelContent.m
//  __PRODUCTNAME__
//
//  Created by Hanlingyu on 16/09/10
//  Copyright (c) apple. All rights reserved.
//

#import "ChannelContent.h"
#import "ChannelImg.h"
#import "ChannelOfChannel.h"
#import "ChannelTags.h"
#import "ChannelHotComment.h"
#import "ChannelVoice.h"

@implementation ChannelContent

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"img"]) {
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            ChannelImg *img = [ChannelImg modelWithDic:dic];
            [array addObject:img];
        }
        _img = array;
    } else if ([key isEqualToString:@"channel"]) {
        ChannelOfChannel *channel = [ChannelOfChannel modelWithDic:value];
        _channel = channel;
    } else if ([key isEqualToString:@"tag"]) {
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            ChannelTags *tag = [ChannelTags modelWithDic:dic];
            [array addObject:tag];
        }
        _tag = array;
    } else if ([key isEqualToString:@"hotComments"]) {
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            ChannelHotComment *hot = [ChannelHotComment modelWithDic:dic];
            [array addObject:hot];
        }
        _hotComments = array;
    } else if ([key isEqualToString:@"voice"]) {
        ChannelVoice *voice = [ChannelVoice modelWithDic:value];
        _voice = voice;
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    [super setValue:value forUndefinedKey:key];
    if ([key isEqualToString:@"id"]) {
        _ID = value;
    }
}



+ (NSDictionary *)objectClassInArray{
    return @{@"img" : [ChannelImg class]};
}

@end
